package com.mdc.mansion.common.mapper;

import java.io.IOException;
import java.text.ParseException;
import java.util.Date;

import com.mdc.mansion.common.util.DateUtils;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
public class JsonDateDeserializer extends JsonDeserializer<Date>{

	@Override
	public Date deserialize(JsonParser jp, DeserializationContext ctxt)
			throws IOException, JsonProcessingException {
		String value = jp.getText();
		try {
			return DateUtils.parseStandardDateTime(value);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	    return null;
	}

}
